package com.coolbi.security.dao.impl;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;

import com.coolbi.security.dao.UserGroupDao;
import com.coolbi.security.entity.UserGroup;
import com.coolbi.security.mapper.UserGroupMapper;

public class UserGroupDaoImpl implements UserGroupDao {
	
	@Autowired
	private UserGroupMapper userGroupMapper;
	public void setUserGroupMapper(UserGroupMapper userGroupMapper) {
		this.userGroupMapper = userGroupMapper;
	}

	@Override
	public List<UserGroup> find(Map<String, Object> parameter) {
		return userGroupMapper.listByParameter(parameter);
	}

	@Override
	public List<UserGroup> find(Map<String, Object> parameter, int offset, int limit) {
		parameter.put("offset", offset);
		parameter.put("limit", limit);
		return userGroupMapper.listByParameterPage(parameter);
	}

	@Override
	public int count(Map<String, Object> parameter) {
		return userGroupMapper.countByParameter(parameter);
	}

	@Override
	public List<UserGroup> search(String keyword, int offset, int limit) {
		Map<String, Object> parameter=new HashMap<String, Object>();
		parameter.put("keyword", keyword);
		parameter.put("offset", offset);
		parameter.put("limit", limit);
		return userGroupMapper.search(parameter);
	}

	@Override
	public int countByKeyword(String keyword) {
		Map<String, Object> parameter=new HashMap<String, Object>();
		parameter.put("keyword", keyword);
		return userGroupMapper.countByKeyword(parameter);
	}

	@Override
	public UserGroup save(UserGroup obj) {
		userGroupMapper.save(obj);
		return obj;
	}

	@Override
	public int update(UserGroup obj) {
		return userGroupMapper.update(obj);
	}

	@Override
	public int delete(long id) {
		return userGroupMapper.delete(id);
	}

	@Override
	public UserGroup get(long id) {
		return userGroupMapper.get(id);
	}

	@Override
	public List<UserGroup> list() {
		return userGroupMapper.list();
	}

	@Override
	public List<UserGroup> list(int offset, int limit) {
		Map<String, Object> parameter=new HashMap<String, Object>();
		parameter.put("offset", offset);
		parameter.put("limit", limit);
		return userGroupMapper.listByPage(parameter);
	}

	@Override
	public int count() {
		return userGroupMapper.count();
	}

}
